﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Zocono.WCS.Domain.DomainRepository;
using Zocono.WCS.Domain.EntityInfo;
using Zocono.WCS.Infrastructure.ApllicationDto.DtoWcsManage;

namespace Zocono.WCS.Domain.ElevatorManage
{
    public class ElevatorInfoService : IElevatorInfoService
    {
        public IElevatorInfoRepository _IElevatorInfoRepository;
        public AutoMapper.IMapper _Mapper;
        public ElevatorInfoService(IElevatorInfoRepository elevatorInfoRepository, AutoMapper.IMapper mapper)
        {
            _IElevatorInfoRepository = elevatorInfoRepository;
            _Mapper= mapper;
        }

        public async Task<ElevatorInfoDto> GetElevatorInfoById(long id)
        {
            var elevators = await _IElevatorInfoRepository.GetByIdAsync(id);
            var elevatorDtos = _Mapper.Map<ElevatorInfo, ElevatorInfoDto>(elevators);
            return elevatorDtos;
        }

        public async Task<List<ElevatorInfoDto>> GetElevatorInfos()
        {
            var elevators =await _IElevatorInfoRepository.GetListAsync();
            var elevatorDtos = _Mapper.Map<List<ElevatorInfo>, List<ElevatorInfoDto>>(elevators);

            return elevatorDtos;
        }

        public async Task<bool> UpdateElevatorInfos(ElevatorInfoDto elevatorInfoDto)
        {

            var elevatorDtos = _Mapper.Map<ElevatorInfoDto, ElevatorInfo>(elevatorInfoDto);
            var res = await _IElevatorInfoRepository.UpdateAsync(elevatorDtos);
            return res;
        }
    }
}
